<template>
  <div class="container">
    <div class="title">
      <span>隐私设置</span>
    </div>
    <el-divider></el-divider>
    <el-form label-width="180px">
      <div class="wrap">
        <el-form-item label="隐私说明">
          <div class="lin-wrap">
            <tinymce :defaultContent="privacy" @change="change" />
          </div>
        </el-form-item>
<!--        <el-form-item label="加入我们">-->
<!--          <div class="lin-wrap">-->
<!--            <tinymce :defaultContent="advertisement" @change="changeOne" />-->
<!--          </div>-->
<!--        </el-form-item>-->
        <el-form-item class="submit">
          <el-button type="primary" @click="createData()">保 存</el-button>
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script>
import System from '@/models/system'
import Tinymce from '@/components/base/tinymce'

export default {
  components: {
    Tinymce,
  },
  data() {
    return {
      privacy: '',
      advertisement: '',
    }
  },
  mounted() {
    this.getInfo()
  },
  methods: {
    async getInfo() {
      const info = await System.getSystem()
      this.privacy = info.privacy
      this.advertisement = info.advertisement
    },
    async createData() {
      const self = this
      const info = {
        privacy: self.privacy,
        advertisement: self.advertisement,
      }
      const res = await System.updateSystem(info)
      if (res.error_code === 0) {
        this.$message.success(`${res.msg}`)
        this.getInfo()
      }
    },
    change(val) {
      this.privacy = val
    },
    changeOne(val) {
      this.advertisement = val
    },
  },
}
</script>

<style lang="scss" scoped>
.el-divider--horizontal {
  margin: 0;
}

.container {
  .title {
    height: 59px;
    line-height: 59px;
    color: $parent-title-color;
    font-size: 16px;
    font-weight: 500;
    text-indent: 40px;

    .back {
      float: right;
      margin-right: 40px;
      cursor: pointer;
    }
  }

  .wrap {
    padding: 20px;
  }

  .submit {
    float: left;
  }
}
</style>
